<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "data".
 *
 * @property string $id
 * @property string $name
 * @property string $title
 * @property string $description
 * @property integer $status
 * @property string $version
 * @property string $create_time
 * @property integer $is_show
 */
class Data extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'data';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['description'], 'string'],
            [['status', 'is_show'], 'integer'],
            [['create_time'], 'safe'],
            [['name'], 'string', 'max' => 40],
            [['title', 'version'], 'string', 'max' => 20],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '主键',
            'name' => '插件名或标识',
            'title' => '中文名',
            'description' => '插件描述',
            'status' => '状态',
            'version' => '版本号',
            'create_time' => '安装时间',
            'is_show' => '是否显示',
        ];
    }

    public function afterFind()
    {
        $this->create_time = date('Y-m-d H:i',$this->create_time);
        parent::afterFind(); // TODO: Change the autogenerated stub
    }


    public function beforeSave($insert)
    {
//        var_dump($this);exit;
        $this->create_time = strtotime($this->create_time);
        return parent::beforeSave($insert); // TODO: Change the autogenerated stub
    }


}
